import 'package:flutter/cupertino.dart';

extension BuildContextExt on BuildContext {
  RenderBox? renderBox() {
    return findRenderObject() is RenderBox ? (findRenderObject() as RenderBox) : null;
  }

  Offset? position({ Offset offset = Offset.zero }) {
    return renderBox()?.localToGlobal(offset);
  }
}

extension GlobalKeyExt on GlobalKey {
  RenderBox? renderBox() => currentContext?.renderBox();

  Offset? position() => currentContext?.position();

  Size? get size => currentContext?.size;
}